{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>新增课程</h5>
                </div>
                <div class="ibox-content layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item ">

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">课程标题：</label>
                            <div class="layui-input-block">
                                <input type="text" name="class_title" lay-verify="required" placeholder="课程标题" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">课程主图：</label>
                            <input type="hidden" name="class_thumb" id="lay-img" lay-verify="image">
                            <div class="layui-input-block">
                                <div id="lay-upload">上传图片</div>
                                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                    预览图：
                                    <div class="layui-upload-list" id="lay-list">
                                    </div>
                                </blockquote>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                            <label class="layui-form-label">课程图集：</label>
                            <div class="layui-input-block">
                                <input type="hidden" name="class_images" id="photo" lay-verify="image">
                                <div id="uploader" class="container-s">
                                    <div class="queueList">
                                        <div class="placeholder">
                                            <div id="filePicker"></div>
                                            <p>或将照片拖到这里</p>
                                        </div>
                                    </div>
                                    <div class="statusBar" style="display:none;">
                                        <div class="layui-progress layui-progress-big active-s" lay-showpercent="true">
                                            <div class="layui-progress-bar layui-bg-blue" lay-percent="0%">
                                            </div>
                                            <span></span>
                                        </div>
                                        <div class="info"></div>
                                        <div class="btns">
                                            <div id="goPicker" class="filePicker2"></div>
                                            <div class="uploadBtn">开始上传</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">课程分类：</label>
                            <div class="layui-input-block">
                                <select name="class_cate_id" lay-search="" id="class_cate_id"  lay-filter="class_cate_id">
                                    {foreach name="cate" item="vo"}
                                    <option value="{$vo.c_cate_id}" >{$vo.c_cate_name}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 form-group">
                            <label class="layui-form-label">观看权限：</label>
                            <div class="layui-input-block">
                                <input type="checkbox" name="class_user_rule[]" value="1" title="普通用户">
                                <input type="checkbox" name="class_user_rule[]" value="2" title="特惠商品">
                                <input type="checkbox" name="class_user_rule[]" value="3" title="脖脸皮">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 form-group">
                            <label class="layui-form-label">课程类型：</label>
                            <div class="layui-input-block">
                                <input type="radio" name="class_type" value="1" class="layui-input" title="免费"/>
                                <input type="radio" name="class_type" value="2" class="layui-input" title="付费"/>
                                <input type="radio" name="class_type" value="3" class="layui-input" title="兑换码"/>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">价格：</label>
                            <div class="layui-input-block">
                                <input type="text" name="class_price" lay-verify="required" placeholder="如果免费或兑换码，请填写0" class="layui-input" oninput="value=value.replace(/[^\d.]/g,'')">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 form-group">
                            <label class="layui-form-label">是否推荐：</label>
                            <div class="layui-input-block">
                                <input type="radio" name="class_is_recommend" value="1" class="layui-input" title="推荐"/>
                                <input type="radio" name="class_is_recommend" value="2" class="layui-input" title="不推荐"/>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 form-group">
                            <label class="layui-form-label">是否热门：</label>
                            <div class="layui-input-block">
                                <input type="radio" name="class_is_hot" value="1" class="layui-input" title="热门"/>
                                <input type="radio" name="class_is_hot" value="2" class="layui-input" title="非热门"/>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 form-group">
                            <label class="layui-form-label">状态：</label>
                            <div class="layui-input-block">
                                <input type="radio" name="class_status" value="1" class="layui-input" title="上架"/>
                                <input type="radio" name="class_status" value="2" class="layui-input" title="下架"/>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 form-group">
                            <label class="layui-form-label">课程形式：</label>
                            <div class="layui-input-block">
                                <input type="radio" name="class_video_audio" value="1" class="layui-input" title="视频"/>
                                <input type="radio" name="class_video_audio" value="2" class="layui-input" title="音频"/>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">适用人群：</label>
                            <div class="layui-input-block">
                                <textarea name="class_shiyong_user" placeholder="" class="layui-textarea"></textarea>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">讲师姓名：</label>
                            <div class="layui-input-block">
                                <input type="text" name="class_teacher_name" lay-verify="required" placeholder="" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">讲师头像：</label>
                            <input type="hidden" name="class_teacher_image" id="lay-img1" lay-verify="image">
                            <div class="layui-input-block">
                                <div id="lay-upload1">上传图片</div>
                                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                    预览图：
                                    <div class="layui-upload-list" id="lay-list1">
                                    </div>
                                </blockquote>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">讲师介绍：</label>
                            <div class="layui-input-block">
                                <textarea name="class_teacher_intro" placeholder="" class="layui-textarea"></textarea>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 form-group">
                            <label class="layui-form-label">课程时效：</label>
                            <div class="layui-input-block">
                                <input type="radio" name="class_is_forever" value="2" class="layui-input" title="无时效"/>
                                <input type="radio" name="class_is_forever" value="1" class="layui-input" title="有时效"/>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">时效天数：</label>
                            <div class="layui-input-block">
                                <input type="text" name="class_valid_date" lay-verify="required" placeholder="时效天数，无时效请填写0" class="layui-input" oninput="value=value.replace(/[^\d]/g,'')">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                            <label class="layui-form-label">课程详情：</label>
                            <div class="layui-input-block" id="LAY_editor" lay-verify="editor">
                                <p></p>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                                </button>
                                <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

{include file="public/footer" /}
<script>
    wk.uploadImg({size:5,type:'png,jpg,jpeg',url:"{:url('Upload/upload')}",domain:""});
    wk.uploadImg({size:5,type:'png,jpg,jpeg',url:"{:url('Upload/upload')}",domain:"",num:1});
    var n = wk.uploads({num:6,type:'png,jpg,jpeg',url:"{:url('admin/upload/upload')}"});
    function imgDel(e,obj){
        wk.uploads_del(e,obj,n); // 删除
    }
    var editor = wk.wang({elem:'#LAY_editor'});
    layui.use(['form','upload','layedit','laydate'], function() {
        var form = layui.form;
        form.verify({
            editor:function(value,item){
                if(editor.txt.html() == '<p><br></p>'){
                    return '请填写内容';
                }
            }
        });

        form.on('submit(component-form-element)', function (data) {
            data.field.class_intro = editor.txt.html();
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('classAdd')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        wk.success(res.msg,"{:url('Classes/index')}")
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            });
        });
    });
</script>

</body>
</html>